﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderList.aspx.cs" Inherits="Cxx.OrderManagerSys.OrderList" %>
<%@ Register TagPrefix="webdiyer" Namespace="Wuqi.Webdiyer" Assembly="AspNetPager, Version=7.5.1.0, Culture=neutral, PublicKeyToken=fb0a0fe055d40fd4" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>建鑫化工生产管理系统</title>
    <link href="UI/dui.min.css" rel="stylesheet" />
    <link href="UI/ui_k.css" rel="stylesheet" />
    <link rel="shortcut icon" type="image/x-icon" href="https://production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" />
    <link rel="mask-icon" type="" href="https://production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" />
    <link rel="stylesheet prefetch" href="https://static.tcy365.com/cdn/bootstrap/3.3.7/custom/1.0.2/css/bootstrap.min.css" />
    <link rel="stylesheet" href="laydate/theme/default/laydate.css" />
    <link rel="stylesheet" href="layui/css/layui.css" />
    <script src="laydate/laydate.js"></script>
    <script src="layui/layui.all.js"></script>
    <script src="JS/jquery-1-7-2.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="layui-layout layui-layout-admin">
            <div class="layui-header">
                <div class="layui-logo">建鑫化工生产管理系统</div>
                <ul class="layui-nav layui-layout-left">
                </ul>
                <ul class="layui-nav layui-layout-right">
                    <li class="layui-nav-item">
                    </li>
                    <li class="layui-nav-item"></li>
                </ul>
            </div>
            <div class="layui-side layui-bg-black">
                <div class="layui-side-scroll">
                    <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                    <ul class="layui-nav layui-nav-tree" lay-filter="test">
                        <li class="layui-nav-item layui-this"><a href="javascript:;">订单管理</a></li>
                        <li class="layui-nav-item"><a href="/CalculateTotal.aspx">客户订单总额计算</a></li>
                        <li class="layui-nav-item"><a href="/StackManage.aspx">库存管理</a></li>
                        <li class="layui-nav-item"><a href="/StockRecordManage.aspx">库存操作记录</a></li>
                    </ul>
                </div>
            </div>
            <div class="layui-body">
                <!-- 内容主体区域 -->
                <div style="padding: 15px;">
                    <div class="ml10 mr10">
                        <div class="mt10 mb10">
                            <button type="button" class="btn btn-sm btn-warning" onclick="OpenDetail(0,'')">
                                <span class="glyphicon glyphicon-plus"></span>添加订单
                            </button>
                        </div>
                        <div class="d-panel mb10">
                            <h3 class="arrow">
                                <strong>查询</strong><a class="close"></a></h3>
                            <div id="screenItems" runat="server" class="content nopadding">
                                <asp:Panel ID="pnlSearch" runat="server" class="d-seach">
                                    <div class="d-seach">
                                        <div class="d-seach-rank">
                                            <span>单号:</span>
                                            <asp:TextBox ID="txtOrderCode" MaxLength="15" CssClass="d-form-input w100" runat="server"></asp:TextBox>
                                            <span>收货单位:</span>
                                            <asp:TextBox ID="txtCustomerName" MaxLength="11" CssClass="d-form-input w100" runat="server"></asp:TextBox>
                                            <%--<span>名称:</span>
                                            <asp:TextBox ID="txtProductName" MaxLength="10" CssClass="d-form-input w100" runat="server"></asp:TextBox>--%>
                                            <span>结款状态:</span>
                                            <asp:DropDownList runat="server" ID="ddlProductionStatus" CssClass="d-form-select w100" >
                                                <asp:ListItem Value="">全部</asp:ListItem>
                                                <asp:ListItem Value="1">已结</asp:ListItem>
                                                <asp:ListItem Value="0">未结</asp:ListItem>
                                            </asp:DropDownList>
                                            <span>有无单子:</span>
                                            <asp:DropDownList runat="server" ID="ddlHasOrder" CssClass="d-form-select w100" >
                                                <asp:ListItem Value="">全部</asp:ListItem>
                                                <asp:ListItem Value="1">有</asp:ListItem>
                                                <asp:ListItem Value="0">无</asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div class="d-seach-rank">
                                            <%--<span>生产者:</span>
                                            <asp:TextBox ID="txtProducer" CssClass="d-form-input w100" runat="server"></asp:TextBox>--%>
                                            开单日期：<asp:TextBox ID="txtStartTime" CssClass="d-form-input w100" runat="server"></asp:TextBox> &nbsp;至&nbsp; <asp:TextBox ID="txtEndTime" CssClass="d-form-input w100" runat="server"></asp:TextBox>
                                        </div>
                                        <div class="d-seach-sub">
                                            <div class="layui-btn-group">
                                                <asp:Button runat="server" Text="查询" ID="btBrowse" CssClass="layui-btn layui-btn-sm" OnClick="btBrowse_Click" />
                                                <asp:Button runat="server" Text="按收货人导出" ID="btExport" CssClass="layui-btn layui-btn-sm" OnClick="btExportByReceiver_Click" />
                                                <asp:Button runat="server" Text="导出集合表" ID="btExportOneSheet" CssClass="layui-btn layui-btn-sm" OnClick="btExport_Click" />
                                                <a id="aExport" target="_blank" href="" runat="server"></a>
                                            </div>
                                        </div>
                                    </div>
                                </asp:Panel>
                            </div>
                        </div>
                        <div>
                            <div class="content nopadding">
                                <asp:Repeater ID="rptOrderList" runat="server">
                                    <HeaderTemplate>
                                        <table class="layui-table">
                                            <thead>
                                                <tr>
                                                    <td style="width: 5%;">
                                                        <input type="checkbox" id="ckall" />
                                                    </td>
                                                    <td style="width: 10%;">订单号
                                                    </td>
                                                    <td style="width: 15%;">日期
                                                    </td>
                                                    <td style="width: 20%;">收货单位
                                                    </td>
                                                    <td style="width: 20%;">金额
                                                    </td>
                                                    <td style="width: 10%;">是否已结
                                                    </td>
                                                    <td style="width: 10%;">有无单子
                                                    </td>
                                                    <td style="width: 10%;">操作
                                                    </td>
                                                </tr>
                                            </thead>
                                            <tbody>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td>
                                                <input type="checkbox" name="ckpaymented" value="<%#Eval("Id").ToString() %>" />
                                            </td>
                                            <td>
                                                <%#Eval("OrderCode") %>
                                            </td>
                                            <td>
                                                <%#Eval("Time")%>
                                            </td>
                                            <td>
                                                <%#Eval("Receiver")%>
                                            </td>
                                            <td>
                                                <%#Eval("Amount")%>
                                            </td>
                                            <td>
                                                <%#GetPaymented(Eval("Paymented")) %>
                                            </td>
                                            <td>
                                                <%#GetHasOrderStr(Eval("HasOrder")) %>
                                            </td>
                                            <td>
                                                <a class="layui-btn layui-btn-sm" href="javascript:OpenDetail('<%#Eval("Id").ToString()%>','<%#Eval("OrderCode").ToString()%>')">查看订单</a>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>

                            </div>
                            <div class="d-pages-list mt10">
                                <webdiyer:AspNetPager ID="pager" runat="server" showpagerinfo="true" showgoto="true" OnPageChanged="pager_PageIndexChange" />
                            </div>
                            <div>
                                <br/>
                                <input type="button" id="btPaymented" class="layui-btn layui-btn-sm" value="批量结算"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-footer">
                <!-- 底部固定区域 -->
                ©Designed by Xiangzhuan.Kong
            </div>
        </div>
    </form>
</body>
<script>
    
    //执行一个laydate实例
    laydate.render({
        elem: '#txtStartTime' //指定元素
    });
    laydate.render({
        elem: '#txtEndTime' //指定元素
    });
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;
    });

    function OpenDetail(id, code) {
        var url = '';
        if (id == 0) {
            url = 'OrderDetail.aspx';
        } else {
            url = 'OrderDetail.aspx?orderId=' + id;
        }
        var title = '';
        if (id == 0) {
            title = '土豪开单中...';
        } else {
            title = '订单编号【' + code + '】';
        }
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['75%', '90%'],
            content: url,
            end: function() {
                //location.reload();
            }
        }); 
    }

    function Refresh() {
        $('#btBrowse').click();
    }

    $('#ckall').click(function () {
        var checker = $('#ckall');
        var isChecked = checker.is(':checked');
        if (isChecked == false) {
            $("input[name='ckpaymented']").prop("checked", false);
        } else {
            $("input[name='ckpaymented']").prop("checked", true);
        }
    });

    $('#btPaymented').click(function () {
        var checkedArray = [];
        var values = '';
        $('input[name=ckpaymented]:checked').each(function (i, o) {
            checkedArray.push(o.value);
        });
        values = checkedArray.join(',');
        $.ajax({
            type: 'GET',
            url: '/payment.ashx?ids=' + values,
            success: function() {
                alert('操作成功');
                $('#btBrowse').click();
            }
        });
    });
</script>
</html>
